package com.zt.yongxinbao.service.impl;

import com.zt.yongxinbao.service.MallService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

@Service
public class MallServiceImpl implements MallService {
    @Autowired
    private JavaMailSender javaMailSender;
    @Value("${spring.mail.username}")
    private String mailUserName;
    @Override
    public Integer sendMall(String email) {
        SimpleMailMessage message = new SimpleMailMessage();
        int radomInt =(int)((Math.random()*9+1)*100000);
        message.setSubject("修改密码");
        message.setFrom(mailUserName);
        message.setTo(email);
        String string="您的验证码是："+radomInt+"，此验证码只能使用一次，在30分钟内有效。";
        message.setText(string);
        javaMailSender.send(message);
        return  radomInt;
    }
}
